#!/usr/bin/env ruby

# == Synopsis
# This programm makes it possible to query the 
# == Usage
# ruby query.eb [ -h | --help | -? ] [ -n elementnumber ]
#
# elementnumber::
#	The +number+ of an element (eg '6' for Carbon)
#
# == Copyright
# Copyright (c) 2008 Carsten Niehaus <cniehaus at kde dot org>
# Licence GPLv3

require "parser"

require "ostruct"
require "optparse"
require "rdoc/usage"
require 'pp'

#options = {}

class ArgvParser

	#
	# Return a structure describing the options.
	#
	def self.parse(args)
		# The options specified on the command line will be collected in *options*.
		# We set default values here.
		options = OpenStruct.new
		options.number = []

		opts = OptionParser.new do |opts|
			# Mandatory argument.
			opts.on("--number NUMBER", "-n NUMBER", "The NUMBER of the element you want to query for") do |num|
				options.number << num
			end
			
			opts.on("-h", "--help", "-?") do
			       	RDoc::usage
			end
		end

		opts.parse!(args)
		options
	end  # parse()
end  # class OptparseExample

options = ArgvParser.parse(ARGV)

c = ChemicalParser.new
c.read

e = c.element( options.number[0] )

puts e.debug
puts e.value( "EA" ) + " " + e.unit( "EA" )
puts e.value( "EN" ) + " " + e.unit( "EN" )

